package com.yanqu.road.server.pb;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.config.skill.SkillInfo;
import com.yanqu.road.entity.crossorewar.CrossOreStationInfo;
import com.yanqu.road.entity.crossorewar.CrossOreWarNotice;
import com.yanqu.road.entity.crossorewar.CrossOreWarRecord;
import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.entity.enums.ePatronsSkillType;
import com.yanqu.road.entity.enums.eSkillType;
import com.yanqu.road.entity.orewar.*;
import com.yanqu.road.entity.player.*;
import com.yanqu.road.entity.union.UnionInfo;
import com.yanqu.road.logic.pb.PatronsPb;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.pb.patrons.PatronsProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.server.logic.battle.BattleManager;
import com.yanqu.road.server.manger.config.PatronsMgr;
import com.yanqu.road.server.manger.config.SkillMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;

import java.util.ArrayList;
import java.util.List;


public class OreWarPb {

	public static OreWarProto.OreStationTempMsg.Builder parseOreStationTempMsg(long userId,OreStationInfo oreStationInfo) {
		if(null == oreStationInfo){
			return null;
		}
		OreWarProto.OreStationTempMsg.Builder msg = OreWarProto.OreStationTempMsg.newBuilder();
		msg.setActivityId(oreStationInfo.getActivityId());
		msg.setStationId(oreStationInfo.getStationId());
		msg.setOccupyCount(oreStationInfo.getOccupyCount());
		msg.setAverageAbility(oreStationInfo.getAverageAbility().toString());
		msg.setIsBlowout(oreStationInfo.isBlowout());
		msg.setUnionUid(oreStationInfo.getUnionUid());
		msg.setUnionName(oreStationInfo.getUnionName());
		msg.setIsSelfOcc(oreStationInfo.containsUserId(userId));
		return msg;
	}



	public static OreWarProto.OrePitTempMsg.Builder parseOrePitTempMsg(UserOrePit userOrePit) {
		if(null == userOrePit){
			return null;
		}
		OreWarProto.OrePitTempMsg.Builder msg = OreWarProto.OrePitTempMsg.newBuilder();
		msg.setActivityId(userOrePit.getActivityId());
		msg.setPitId(userOrePit.getPitId());
		msg.setStationId(userOrePit.getStationId());
		msg.setUserId(userOrePit.getUserId());
		msg.setServerId( GameServer.getInstance().getServerId());
		msg.setNickName(userOrePit.getNickName());
		msg.setDecoration(userOrePit.getDecoration());
		msg.setTitleId(1);
		msg.setCity("");
		msg.setUnionName("");
		msg.setUnionUid("");
		UserInfo userInfo = UserMgr.getUserInfo(userOrePit.getUserId());
		if(userInfo != null){
			msg.setDecoration(userInfo.getDecoration());
			UnionInfo info = CrossUnionMgr.getUnionInfo(userInfo.getUnionUid());
			if(info != null){
				msg.setUnionName(info.getUnionName());
				msg.setUnionUid(info.getUnionUid());
			}
		}
		return msg;
	}



	public static OreWarProto.MyOrePitTempMsg.Builder parseMyOrePitTempMsg(UserOrePit userOrePit, boolean isRemove) {
		if(null == userOrePit){
			return null;
		}
		OreWarProto.MyOrePitTempMsg.Builder msg = OreWarProto.MyOrePitTempMsg.newBuilder();
		msg.setActivityId(userOrePit.getActivityId());
		msg.setPitId(userOrePit.getPitId());
		msg.setIsRemove(isRemove);
		msg.setIsNaming(userOrePit.isNaming());
		if(!isRemove){
			msg.setLastGetRewardTime(userOrePit.getLastGetRewardTime());
			if (null != userOrePit.getPatronsIdList()) {
				msg.addAllPatronsIdList(userOrePit.getPatronsIdList());
			}
		}
		return msg;
	}

	public static OreWarProto.OreWarRecordTempMsg.Builder parseOreWarRecordTempMsg(OreWarRecord oreWarRecord) {
		if(null == oreWarRecord){
			return null;
		}
		OreWarProto.OreWarRecordTempMsg.Builder msg = OreWarProto.OreWarRecordTempMsg.newBuilder();
		msg.setRecordUid(oreWarRecord.getRecordUid());
		msg.setActivityId(oreWarRecord.getActivityId());
		msg.setPitId(oreWarRecord.getPitId());
		msg.setEnemyUserId(oreWarRecord.getEnemyUserId());
		PlayerProto.PlayerBaseTempMsg.Builder baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(oreWarRecord.getEnemyBaseData());
		msg.setEnemyBaseData(baseMsg);
		msg.setRecordTime(oreWarRecord.getRecordTime());
		msg.setIsWin(oreWarRecord.isWin());
		return msg;
	}



	public static OreWarProto.OreWarNoticeTempMsg.Builder parseOreWarNoticeTempMsg(OreWarNotice oreWarNotice) {
		if(null == oreWarNotice){
			return null;
		}
		OreWarProto.OreWarNoticeTempMsg.Builder msg = OreWarProto.OreWarNoticeTempMsg.newBuilder();
		msg.setNoticeUid(oreWarNotice.getNoticeUid());
		msg.setActivityId(oreWarNotice.getActivityId());
		msg.setPitId(oreWarNotice.getPitId());
		msg.setNoticeTime(oreWarNotice.getNoticeTime());
		msg.setUserId(oreWarNotice.getUserId());
		PlayerProto.PlayerBaseTempMsg.Builder baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(oreWarNotice.getUserBaseInfo());
		msg.setPlayerBaseData(baseMsg);
		msg.setEnemyUserId(oreWarNotice.getEnemyUserId());
		baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(oreWarNotice.getEnemyBaseInfo());
		msg.setEnemyBaseData(baseMsg);
		return msg;
	}

	public static OreWarProto.OreRefugeTempMsg.Builder parseOreRefugeTempMsg(UserOreRefuge userOreRefuge) {
		if(null == userOreRefuge){
			return null;
		}
		OreWarProto.OreRefugeTempMsg.Builder msg = OreWarProto.OreRefugeTempMsg.newBuilder();
		msg.setActivityId(userOreRefuge.getActivityId());
		msg.setPitId(userOreRefuge.getPitId());
		msg.setLastGetRewardTime(userOreRefuge.getLastGetRewardTime());
		if(null != userOreRefuge.getPatronsIdList()) {
			msg.addAllPatronsIdList(userOreRefuge.getPatronsIdList());
		}
		return msg;
	}

	public static OreWarProto.OreStationListMsg.Builder parseOreStationListMsg(long userId,List<OreStationInfo> oreStationInfoList){
		OreWarProto.OreStationListMsg.Builder listMsg = OreWarProto.OreStationListMsg.newBuilder();
		if(null != oreStationInfoList){
			for(OreStationInfo oreStationInfo : oreStationInfoList){
				OreWarProto.OreStationTempMsg.Builder msg = parseOreStationTempMsg(userId,oreStationInfo);
				if(null != msg){
					listMsg.addOreStationList(msg);
				}
			}
		}
		return listMsg;
	}


	public static OreWarProto.OrePitListMsg.Builder parseOrePitListMsg(List<UserOrePit> userOrePitList){
		OreWarProto.OrePitListMsg.Builder listMsg = OreWarProto.OrePitListMsg.newBuilder();
		if(null != userOrePitList){
			for(UserOrePit userOrePit : userOrePitList){
				OreWarProto.OrePitTempMsg.Builder msg = parseOrePitTempMsg(userOrePit);
				if(null != msg){
					listMsg.addOrePitList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.OreTopBuildingDetailRespMsg.Builder parseOreTopBuildingDetailRespMsg(List<UserOrePit> userOrePitList){
		OreWarProto.OreTopBuildingDetailRespMsg.Builder respMsg = OreWarProto.OreTopBuildingDetailRespMsg.newBuilder();
		respMsg.setRet(0);
		if(null != userOrePitList){
			for(UserOrePit userOrePit : userOrePitList){
				if(userOrePit.getUserId() != 0){
					OreWarProto.OreTopBuildingDetailTempMsg.Builder msg = parseOreTopBuildingDetailTempMsg(userOrePit);
					if(null != msg){
						respMsg.addInfos(msg);
					}
				}
			}
		}
		return respMsg;
	}

	private static OreWarProto.OreTopBuildingDetailTempMsg.Builder parseOreTopBuildingDetailTempMsg(UserOrePit userOrePit) {
		if(null == userOrePit){
			return null;
		}
		OreWarProto.OreTopBuildingDetailTempMsg.Builder msg = OreWarProto.OreTopBuildingDetailTempMsg.newBuilder();
		msg.setPitId(userOrePit.getPitId());
		msg.setUserId(userOrePit.getUserId());
		msg.setPatronsCount(userOrePit.getPatronsIdList().size());
		List<UserPatrons> patronsList = BattleManager.getCalOreWarEarnSpeed(userOrePit.getPatronsList());
		msg.setTotalAbility(PatronsMgr.getOreWarPatronsListEarnSpeed(patronsList).longValue());
		UserInfo userInfo = UserMgr.getUserInfo(userOrePit.getUserId());
		if(null != userInfo)
			msg.setPlayerBaseData(PlayerBasePb.parsePlayerBaseTempMsg(UserMgr.parseUserBaseInfo(userInfo, GameServer.getInstance().getServerId())));
		for (UserPatrons userPatrons : patronsList) {
			PatronsProto.PatronsTempMsg.Builder patronsMsg = PatronsPb.parsePatronsTempMsg(userPatrons);
			if (null != patronsMsg) {
				msg.addPatronsList(patronsMsg);
			}
		}
		return msg;
	}

	public static OreWarProto.OreTopBuildingDetailRespMsg.Builder parseCrossOreTopBuildingDetailRespMsg(List<CrossUserOrePit> crossUserOrePitList){
		OreWarProto.OreTopBuildingDetailRespMsg.Builder respMsg = OreWarProto.OreTopBuildingDetailRespMsg.newBuilder();
		respMsg.setRet(0);
		if(null != crossUserOrePitList){
			for(CrossUserOrePit crossUserOrePit : crossUserOrePitList){
				if(crossUserOrePit.getUserId() != 0){
					OreWarProto.OreTopBuildingDetailTempMsg.Builder msg = parseCrossOreTopBuildingDetailTempMsg(crossUserOrePit);
					if(null != msg){
						respMsg.addInfos(msg);
					}
				}
			}
		}
		return respMsg;
	}

	private static OreWarProto.OreTopBuildingDetailTempMsg.Builder parseCrossOreTopBuildingDetailTempMsg(CrossUserOrePit crossUserOrePit) {
		if(null == crossUserOrePit){
			return null;
		}
		OreWarProto.OreTopBuildingDetailTempMsg.Builder msg = OreWarProto.OreTopBuildingDetailTempMsg.newBuilder();
		msg.setPitId(crossUserOrePit.getPitId());
		msg.setUserId(crossUserOrePit.getUserId());
		msg.setPatronsCount(crossUserOrePit.getPatronsList().size());
		List<UserPatrons> patronsList = BattleManager.getCalOreWarEarnSpeed(crossUserOrePit.getPatronsList());
		msg.setTotalAbility(PatronsMgr.getOreWarPatronsListEarnSpeed(patronsList).longValue());
		msg.setPlayerBaseData(PlayerBasePb.parsePlayerBaseTempMsg(crossUserOrePit.getUserBaseInfo()));
		for (UserPatrons userPatrons : patronsList) {
			PatronsProto.PatronsTempMsg.Builder patronsMsg = PatronsPb.parsePatronsTempMsg(userPatrons);
			if (null != patronsMsg) {
				msg.addPatronsList(patronsMsg);
			}
		}
		return msg;
	}




	public static OreWarProto.MyOrePitListMsg.Builder parseMyOrePitListMsg(int activityId,List<UserOrePit> userOrePitList, boolean isRemove){
		OreWarProto.MyOrePitListMsg.Builder listMsg = OreWarProto.MyOrePitListMsg.newBuilder();
		listMsg.setActivityId(activityId);
		if(null != userOrePitList){
			for(UserOrePit userOrePit : userOrePitList){
				OreWarProto.MyOrePitTempMsg.Builder msg = parseMyOrePitTempMsg(userOrePit, isRemove);
				if(null != msg){
					listMsg.addOrePitList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.OreWarHpMsg.Builder parseOreWarHpMsg(UserOreWarHp userOreWarHp){
		OreWarProto.OreWarHpMsg.Builder msg = OreWarProto.OreWarHpMsg.newBuilder();
		if(null != userOreWarHp){
			msg.setActivityId(userOreWarHp.getActivityId());
			msg.setHp(userOreWarHp.getHp());
			msg.setLastUpdateTime((int)(userOreWarHp.getLastUpdateTime()/1000));
		}
		return msg;
	}

	public static OreWarProto.OreWarRecordListMsg.Builder parseOreWarRecordListMsg(List<OreWarRecord> oreWarRecordList){
		OreWarProto.OreWarRecordListMsg.Builder listMsg = OreWarProto.OreWarRecordListMsg.newBuilder();
		if(null != oreWarRecordList){
			for(OreWarRecord oreWarRecord : oreWarRecordList){
				OreWarProto.OreWarRecordTempMsg.Builder msg = parseOreWarRecordTempMsg(oreWarRecord);
				if(null != msg){
					listMsg.addOreWarRecordList(msg);
				}
			}
		}
		return listMsg;
	}



	public static OreWarProto.OreWarNoticeListMsg.Builder parseOreWarNoticeListMsg(List<OreWarNotice> oreWarNoticeList){
		OreWarProto.OreWarNoticeListMsg.Builder listMsg = OreWarProto.OreWarNoticeListMsg.newBuilder();
		if(null != oreWarNoticeList){
			for(OreWarNotice oreWarNotice : oreWarNoticeList){
				OreWarProto.OreWarNoticeTempMsg.Builder msg = parseOreWarNoticeTempMsg(oreWarNotice);
				if(null != msg){
					listMsg.addOreWarNoticeList(msg);
				}
			}
		}
		return listMsg;
	}



	public static OreWarProto.OreRefugeListMsg.Builder parseOreRefugeListMsg(List<UserOreRefuge> userOreRefugeList){
		OreWarProto.OreRefugeListMsg.Builder listMsg = OreWarProto.OreRefugeListMsg.newBuilder();
		if(null != userOreRefugeList){
			for(UserOreRefuge userOreRefuge : userOreRefugeList){
				OreWarProto.OreRefugeTempMsg.Builder msg = parseOreRefugeTempMsg(userOreRefuge);
				if(null != msg){
					listMsg.addOreRefugeList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.OreWarPatronsDataTempMsg.Builder parseOreWarPatronsDataTempMsg(UserOreWarPatronsData userOreWarPatronsData){
		if(null == userOreWarPatronsData){
			return null;
		}
		OreWarProto.OreWarPatronsDataTempMsg.Builder msg = OreWarProto.OreWarPatronsDataTempMsg.newBuilder();
		msg.setPatronsId(userOreWarPatronsData.getPatronsId());
		msg.setBattleTimes(userOreWarPatronsData.getBattleTimes());
		msg.setBuyBattleTimes(userOreWarPatronsData.getBuyBattleTimes());
		msg.setIsDispatchOre(userOreWarPatronsData.getDispatchOre() > 0);
		msg.setActivityId(userOreWarPatronsData.getActivityId());
		return msg;
	}

	public static OreWarProto.OreWarPatronsDataListMsg.Builder parseOreWarPatronsDataListMsg(List<UserOreWarPatronsData> userOreWarPatronsDataList){
		OreWarProto.OreWarPatronsDataListMsg.Builder listMsg = OreWarProto.OreWarPatronsDataListMsg.newBuilder();
		if(null != userOreWarPatronsDataList){
			for(UserOreWarPatronsData userOreWarPatronsData : userOreWarPatronsDataList){
				OreWarProto.OreWarPatronsDataTempMsg.Builder msg = parseOreWarPatronsDataTempMsg(userOreWarPatronsData);
				if(null != msg){
					listMsg.addPatronsDataList(msg);
				}
			}
		}
		return listMsg;
	}



	/*****************************************跨服下来的*************************************************************************************************************************/

	//同步用户基础信息，用于商会同名的变化
	public static OreWarProto.CrossUserBaseInfoSyncMsg.Builder parseCrossUserBaseInfoSyncMsg(int activityId, List<Long> userIdList) {
		if(null == userIdList){
			return null;
		}
		OreWarProto.CrossUserBaseInfoSyncMsg.Builder msg = OreWarProto.CrossUserBaseInfoSyncMsg.newBuilder();
		msg.setServerId(GameServer.getInstance().getServerId());
		for(long userId : userIdList){
			OreWarProto.CrossUserBaseInfoTempMsg.Builder tempMsg = parseCrossUserBaseInfoTempMsg(userId);
			msg.addSyncInfo(tempMsg);
		}
		msg.setActivityId(activityId);
		return msg;
	}

	public static OreWarProto.CrossUserBaseInfoTempMsg.Builder parseCrossUserBaseInfoTempMsg(long userId) {
		OreWarProto.CrossUserBaseInfoTempMsg.Builder msg = OreWarProto.CrossUserBaseInfoTempMsg.newBuilder();
		msg.setUserId(userId);
		UserBaseInfo userBaseInfo = UserMgr.getUserBaseInfo(userId,GameServer.getInstance().getServerId());
		if(null != userBaseInfo){
			msg.setPlayerBaseData(PlayerBasePb.parsePlayerBaseTempMsg(userBaseInfo));
		}
		return msg;
	}

	public static OreWarProto.OreStationTempMsg.Builder parseCrossOreStationTempMsg(long userId,CrossOreStationInfo crossOreStationInfo) {
		if(null == crossOreStationInfo){
			return null;
		}
		OreWarProto.OreStationTempMsg.Builder msg = OreWarProto.OreStationTempMsg.newBuilder();
		msg.setActivityId(crossOreStationInfo.getActivityId());
		msg.setStationId(crossOreStationInfo.getStationId());
		msg.setOccupyCount(crossOreStationInfo.getOccupyCount());
		msg.setAverageAbility(crossOreStationInfo.getAverageAbility().toString());
		msg.setIsBlowout(crossOreStationInfo.isBlowout());
		msg.setUnionUid(crossOreStationInfo.getUnionUid());
		msg.setUnionName(crossOreStationInfo.getUnionName());
		msg.setIsSelfOcc(crossOreStationInfo.containsUserId(userId));
		return msg;
	}

	public static OreWarProto.OrePitTempMsg.Builder parseCrossOrePitTempMsg(CrossUserOrePit crossUserOrePit) {
		if(null == crossUserOrePit){
			return null;
		}
		OreWarProto.OrePitTempMsg.Builder msg = OreWarProto.OrePitTempMsg.newBuilder();
		msg.setActivityId(crossUserOrePit.getActivityId());
		msg.setPitId(crossUserOrePit.getPitId());
		msg.setStationId(crossUserOrePit.getStationId());
		msg.setUserId(crossUserOrePit.getUserId());
		msg.setServerId(crossUserOrePit.getServerId());
		msg.setNickName(crossUserOrePit.getNickName());
		msg.setDecoration(crossUserOrePit.getUserBaseInfo().getDecoration());
		msg.setTitleId(crossUserOrePit.getUserBaseInfo().getTitleId());
		msg.setCity(crossUserOrePit.getUserBaseInfo().getCity());
		msg.setUnionName(crossUserOrePit.getUserBaseInfo().getUnionName());
		msg.setUnionUid(crossUserOrePit.getUserBaseInfo().getUnionUid());
		return msg;
	}

	//跨服记录，虽然是一样的，但是怕不一样新弄一个吧
	public static OreWarProto.OreWarRecordTempMsg.Builder parseCrossOreWarRecordTempMsg(CrossOreWarRecord crossOreWarRecord) {
		if(null == crossOreWarRecord){
			return null;
		}
		OreWarProto.OreWarRecordTempMsg.Builder msg = OreWarProto.OreWarRecordTempMsg.newBuilder();
		msg.setRecordUid(crossOreWarRecord.getRecordUid());
		msg.setActivityId(crossOreWarRecord.getActivityId());
		msg.setPitId(crossOreWarRecord.getPitId());
		msg.setEnemyUserId(crossOreWarRecord.getEnemyUserId());
		PlayerProto.PlayerBaseTempMsg.Builder baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(crossOreWarRecord.getEnemyBaseData());
		msg.setEnemyBaseData(baseMsg);
		msg.setRecordTime(crossOreWarRecord.getRecordTime());
		msg.setIsWin(crossOreWarRecord.isWin());
		return msg;
	}

	//跨服的用户坑位信息
	public static OreWarProto.OrePitListMsg.Builder parseCrossOrePitListMsg(List<CrossUserOrePit> crossUserOrePitList){
		OreWarProto.OrePitListMsg.Builder listMsg = OreWarProto.OrePitListMsg.newBuilder();
		if(null != crossUserOrePitList){
			for(CrossUserOrePit crossUserOrePit : crossUserOrePitList){
				OreWarProto.OrePitTempMsg.Builder msg = parseCrossOrePitTempMsg(crossUserOrePit);
				if(null != msg){
					listMsg.addOrePitList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.OreWarNoticeTempMsg.Builder parseCrossOreWarNoticeTempMsg(CrossOreWarNotice crossOreWarNotice) {
		if(null == crossOreWarNotice){
			return null;
		}
		OreWarProto.OreWarNoticeTempMsg.Builder msg = OreWarProto.OreWarNoticeTempMsg.newBuilder();
		msg.setNoticeUid(crossOreWarNotice.getNoticeUid());
		msg.setActivityId(crossOreWarNotice.getActivityId());
		msg.setPitId(crossOreWarNotice.getPitId());
		msg.setNoticeTime(crossOreWarNotice.getNoticeTime());
		msg.setUserId(crossOreWarNotice.getUserId());
		PlayerProto.PlayerBaseTempMsg.Builder baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(crossOreWarNotice.getUserBaseInfo());
		msg.setPlayerBaseData(baseMsg);
		msg.setEnemyUserId(crossOreWarNotice.getEnemyUserId());
		baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(crossOreWarNotice.getEnemyBaseInfo());
		msg.setEnemyBaseData(baseMsg);
		return msg;
	}

	//跨服的Notice
	public static OreWarProto.OreWarNoticeListMsg.Builder parseCrossOreWarNoticeListMsg(List<CrossOreWarNotice> crossOreWarNoticeList){
		OreWarProto.OreWarNoticeListMsg.Builder listMsg = OreWarProto.OreWarNoticeListMsg.newBuilder();
		if(null != crossOreWarNoticeList){
			for(CrossOreWarNotice crossOreWarNotice : crossOreWarNoticeList){
				OreWarProto.OreWarNoticeTempMsg.Builder msg = parseCrossOreWarNoticeTempMsg(crossOreWarNotice);
				if(null != msg){
					listMsg.addOreWarNoticeList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.OreWarRecordListMsg.Builder parseCrossOreWarRecordListMsg(List<CrossOreWarRecord> crossOreWarRecordList){
		OreWarProto.OreWarRecordListMsg.Builder listMsg = OreWarProto.OreWarRecordListMsg.newBuilder();
		if(null != crossOreWarRecordList){
			for(CrossOreWarRecord crossOreWarRecord : crossOreWarRecordList){
				OreWarProto.OreWarRecordTempMsg.Builder msg = parseCrossOreWarRecordTempMsg(crossOreWarRecord);
				if(null != msg){
					listMsg.addOreWarRecordList(msg);
				}
			}
		}
		return listMsg;
	}

	//跨服的简略信息，当前是一样的内容，可能会有不一样，先预留着
	public static OreWarProto.OreStationListMsg.Builder parseCrossOreStationListMsg(long userId,List<CrossOreStationInfo> crossOreStationInfoList){
		OreWarProto.OreStationListMsg.Builder listMsg = OreWarProto.OreStationListMsg.newBuilder();
		if(null != crossOreStationInfoList){
			for(CrossOreStationInfo crossOreStationInfo : crossOreStationInfoList){
				OreWarProto.OreStationTempMsg.Builder msg = parseCrossOreStationTempMsg(userId,crossOreStationInfo);
				if(null != msg){
					listMsg.addOreStationList(msg);
				}
			}
		}
		return listMsg;
	}

	public static List<CrossUserOrePit> parseCrossOrePitList(List<OreWarProto.CrossOrePitTempMsg> userOreWarPitDataList){
		List<CrossUserOrePit> crossUserOrePitList = new ArrayList<>();
		if(null != userOreWarPitDataList){
			for(OreWarProto.CrossOrePitTempMsg tempMsg : userOreWarPitDataList){
				CrossUserOrePit crossUserOrePit = parseCrossUserOrePit(tempMsg);
				if(null != crossUserOrePit){
					crossUserOrePitList.add(crossUserOrePit);
				}
			}
		}
		return crossUserOrePitList;
	}

	public static List<CrossOreWarRecord> parseCrossOreWarRecordList(List<OreWarProto.CrossOreWarRecordTempMsg> userOreWarRecordDataList){
		List<CrossOreWarRecord> crossOreWarRecordList = new ArrayList<>();
		if(null != userOreWarRecordDataList){
			for(OreWarProto.CrossOreWarRecordTempMsg tempMsg : userOreWarRecordDataList){
				CrossOreWarRecord crossOreWarRecord = parseCrossOreWarRecord(tempMsg);
				if(null != crossOreWarRecord){
					crossOreWarRecordList.add(crossOreWarRecord);
				}
			}
		}
		return crossOreWarRecordList;
	}

	public static List<CrossOreWarNotice> parseCrossOreWarNoticeList(List<OreWarProto.CrossOreWarNoticeTempMsg> userOreWarRecordDataList){
		List<CrossOreWarNotice> crossOreWarNoticeList = new ArrayList<>();
		if(null != userOreWarRecordDataList){
			for(OreWarProto.CrossOreWarNoticeTempMsg tempMsg : userOreWarRecordDataList){
				CrossOreWarNotice crossOreWarNotice = parseCrossOreWarNotice(tempMsg);
				if(null != crossOreWarNotice){
					crossOreWarNoticeList.add(crossOreWarNotice);
				}
			}
		}
		return crossOreWarNoticeList;
	}
	public static CrossOreWarNotice parseCrossOreWarNotice(OreWarProto.CrossOreWarNoticeTempMsg tempMsg){
		if(null == tempMsg){
			return null;
		}
		CrossOreWarNotice crossOreWarNotice = new CrossOreWarNotice();
		crossOreWarNotice.setNoticeUid(tempMsg.getNoticeUid());
		crossOreWarNotice.setActivityId(tempMsg.getActivityId());
		crossOreWarNotice.setPitId(tempMsg.getPitId());
		crossOreWarNotice.setNoticeTime(tempMsg.getNoticeTime());
		crossOreWarNotice.setUserId(tempMsg.getUserId());
		crossOreWarNotice.setServerId(tempMsg.getServerId());
		crossOreWarNotice.setUserBaseInfo(PlayerBasePb.parseBaseUserInfo(tempMsg.getPlayerBaseData()));
		crossOreWarNotice.setEnemyUserId(tempMsg.getEnemyUserId());
		crossOreWarNotice.setEnemyBaseInfo(PlayerBasePb.parseBaseUserInfo(tempMsg.getEnemyBaseData()));
		return crossOreWarNotice;
	}

	public static CrossUserOrePit parseCrossUserOrePit(OreWarProto.CrossOrePitTempMsg tempMsg){
		if(null == tempMsg){
			return null;
		}
		CrossUserOrePit crossUserOrePit = new CrossUserOrePit();
		crossUserOrePit.setActivityId(tempMsg.getActivityId());
		crossUserOrePit.setPitId(tempMsg.getPitId());
		crossUserOrePit.setStationId(tempMsg.getStationId());
		crossUserOrePit.setUserId(tempMsg.getUserId());
		crossUserOrePit.setServerId(tempMsg.getServerId());
		crossUserOrePit.setNickName(tempMsg.getNickName());
		crossUserOrePit.setPatronsInfoStr(tempMsg.getPatronsInfoStr());
		List<UserPatrons> patronsList = JSON.parseArray(tempMsg.getPatronsInfoStr(),UserPatrons.class);
		crossUserOrePit.setPatronsList(patronsList);
		crossUserOrePit.setJoinTime(tempMsg.getJoinTime());
		crossUserOrePit.setLastGetRewardTime(tempMsg.getLastGetRewardTime());
		crossUserOrePit.setBlowout(tempMsg.getIsBlowout());
		crossUserOrePit.setUserBaseInfo(PlayerBasePb.parseBaseUserInfo(tempMsg.getPlayerBaseData()));
		return crossUserOrePit;
	}

	public static CrossOreWarRecord parseCrossOreWarRecord(OreWarProto.CrossOreWarRecordTempMsg tempMsg){
		if(null == tempMsg){
			return null;
		}
		CrossOreWarRecord crossOreWarRecord = new CrossOreWarRecord();
		crossOreWarRecord.setRecordUid(tempMsg.getRecordUid());
		crossOreWarRecord.setUserId(tempMsg.getUserId());
		crossOreWarRecord.setServerId(tempMsg.getServerId());
		crossOreWarRecord.setActivityId(tempMsg.getActivityId());
		crossOreWarRecord.setPitId(tempMsg.getPitId());
		crossOreWarRecord.setEnemyUserId(tempMsg.getEnemyUserId());
		crossOreWarRecord.setEnemyBaseData(PlayerBasePb.parseBaseUserInfo(tempMsg.getEnemyBaseData()));
		crossOreWarRecord.setRecordTime(tempMsg.getRecordTime());
		crossOreWarRecord.setWin(tempMsg.getIsWin());
		return crossOreWarRecord;
	}

	//同步门客信息变动
	public static OreWarProto.CrossPatronsAbilityChangeSyncMsg.Builder parseCrossPatronsAbilityChangeSyncMsg(GamePlayer player,int activityId,int pitId,List<UserPatrons> userPatronsList){
		OreWarProto.CrossPatronsAbilityChangeSyncMsg.Builder syncMsg = OreWarProto.CrossPatronsAbilityChangeSyncMsg.newBuilder();
		syncMsg.setActivityId(activityId);
		syncMsg.setPitId(pitId);
		syncMsg.setPitOwnerUserId(player.getUserId());
		syncMsg.setPatronsInfoStr(JSON.toJSONString(userPatronsList));
		int beautySkillAddition = player.getModule(BeautyModule.class).getIdentitySkillAddition(eSkillType.MineOutput.getValue(), 0);
		syncMsg.setBeautySkillAddition(beautySkillAddition);
		int patronsSkillAddition = 0;
		for(UserPatrons userPatrons : userPatronsList){//计算天赋加成
			for(UserPatronsSkill patronsSkill : userPatrons.getSkillList()){
				if(patronsSkill.getType() != ePatronsSkillType.Talent.getValue()){
					continue;
				}
				SkillInfo skillInfo = SkillMgr.getSkillInfo(patronsSkill.getSkillId());
				if(skillInfo.getType() == eSkillType.MineWarAddOutput.getValue()){
					patronsSkillAddition += SkillMgr.getSkillAddition(skillInfo, patronsSkill.getSkillLv());
				}
			}
		}
		syncMsg.setPatronsSkillAddition(patronsSkillAddition);

		UserInfo userInfo = UserMgr.getUserInfo(player.getUserId());
		UserBaseInfo userBaseInfo = UserMgr.parseUserBaseInfo(userInfo, GameServer.getInstance().getServerId());
		PlayerProto.PlayerBaseTempMsg.Builder baseMsg = PlayerBasePb.parsePlayerBaseTempMsg(userBaseInfo);
		syncMsg.setPlayerBaseData(baseMsg);
		return syncMsg;
	}

	public static OreWarProto.CrossOreWarPatronsSyncMsg.Builder parseCrossOreWarPatronsSyncMsg(GamePlayer player, Integer pitId, List<UserPatrons> userPatronsList) {
		OreWarProto.CrossOreWarPatronsSyncMsg.Builder builder = OreWarProto.CrossOreWarPatronsSyncMsg.newBuilder();
		builder.setPitId(pitId);
		builder.setPitOwnerUserId(player.getUserId());
		builder.setPatronsInfoStr(JSON.toJSONString(userPatronsList));
		int beautySkillAddition = player.getModule(BeautyModule.class).getIdentitySkillAddition(eSkillType.MineOutput.getValue(), 0);
		builder.setBeautySkillAddition(beautySkillAddition);
		int patronsSkillAddition = 0;
		for(UserPatrons userPatrons : userPatronsList){//计算天赋加成
			for(UserPatronsSkill patronsSkill : userPatrons.getSkillList()){
				if(patronsSkill.getType() != ePatronsSkillType.Talent.getValue()){
					continue;
				}
				SkillInfo skillInfo = SkillMgr.getSkillInfo(patronsSkill.getSkillId());
				if(skillInfo.getType() == eSkillType.MineWarAddOutput.getValue()){
					patronsSkillAddition += SkillMgr.getSkillAddition(skillInfo, patronsSkill.getSkillLv());
				}
			}
		}
		builder.setPatronsSkillAddition(patronsSkillAddition);
		return builder;
	}

	public static OreWarProto.MyOrePitListMsg.Builder parseMyCrossOrePitListMsg(int activityId,List<CrossUserOrePit> crossUserOrePitList, boolean isRemove){
		OreWarProto.MyOrePitListMsg.Builder listMsg = OreWarProto.MyOrePitListMsg.newBuilder();
		listMsg.setActivityId(activityId);
		if(null != crossUserOrePitList){
			for(CrossUserOrePit crossUserOrePit : crossUserOrePitList){
				OreWarProto.MyOrePitTempMsg.Builder msg = parseMyCrossOrePitTempMsg(crossUserOrePit, isRemove);
				if(null != msg){
					listMsg.addOrePitList(msg);
				}
			}
		}
		return listMsg;
	}

	public static OreWarProto.MyOrePitTempMsg.Builder parseMyCrossOrePitTempMsg(CrossUserOrePit crossUserOrePit, boolean isRemove) {
		if(null == crossUserOrePit){
			return null;
		}
		OreWarProto.MyOrePitTempMsg.Builder msg = OreWarProto.MyOrePitTempMsg.newBuilder();
		msg.setActivityId(crossUserOrePit.getActivityId());
		msg.setPitId(crossUserOrePit.getPitId());
		msg.setIsRemove(isRemove);
		msg.setIsNaming(crossUserOrePit.isNaming());
		if(!isRemove){
			msg.setLastGetRewardTime(crossUserOrePit.getLastGetRewardTime());
			if (null != crossUserOrePit.getPatronsInfoStr()) {
				msg.addAllPatronsIdList(PatronsMgr.parsePatronInfoStrToIdList(crossUserOrePit.getPatronsInfoStr()));
			}
		}
		return msg;
	}

}
